package com.example.community.service;

//import com.liu.spike.service.KafkaProducerServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;

import javax.annotation.Resource;

/**
 * @className: com.liu.spike.service.impl.KafkaProducerServerImpl
 * @description: TODO
 * @author: liu
 * @create: 2022-05-02 14:26
 */

@Service
public class KafkaProducerServerImpl {
//    @Autowired
    @Resource
    private KafkaTemplate<String,String> kafkaTemplate;

    public void sendToTopic(String topic, String msg) {
        final ListenableFuture<SendResult<String, String>> send = kafkaTemplate.send(topic, msg);

    }
}
